package com.hj.saapp.common.utils;

import android.content.Intent;

import com.hj.saapp.BCDApplication;

import com.hj.saapp.R;
import com.hj.saapp.common.manager.AppManager;
import com.hj.saapp.control.activity.DefaultDialog;


/**
 * 类说明：
 *
 * @author YZ
 * @version 1.0
 * @date May 26, 2015
 */

public class DialogActivityUtil {




    private static DialogActivityUtil dialogUtil = null;

    private DialogActivityUtil() {

    }


    public static DialogActivityUtil getInstance() {
        if (dialogUtil == null) {
            dialogUtil = new DialogActivityUtil();
        }
        return dialogUtil;
    }

    /**
     * 单一按键提示框
     *
     * @param title                 提示
     * @see [类、类#方法、类#成员]
     */
    public void showSoleDialog(String title,boolean isCancelable) {

        showDialog(title,
                null,
                null,
                StringUtils.getStringById(R.string.dialog_verify),isCancelable);
    }

    public void showSoleDialog(String title, String negativeStr,boolean isCancelable) {
        showDialog(title, null, null, negativeStr,isCancelable);
    }

    /**
     * 两个按键提示框
     *
     * @param title                 题目
     * @param positiveStr           确定按键文字
     * @param negativeStr           取消按键文字
     * @see [类、类#方法、类#成员]
     */
    public void showTwoDialog(String title, String positiveStr, String negativeStr,boolean isCancelable) {
        showDialog(title, null, positiveStr, negativeStr,isCancelable);
    }
    /**
     * 两个按键提示框
     *
     * @param title                 题目
     * @param positiveStr           确定按键文字
     * @param negativeStr           取消按键文字
     * @see [类、类#方法、类#成员]
     */
    public void showTwoDialog(String title, String positiveStr, String negativeStr,String popType,boolean showEditText,boolean isCancelable) {
        showDialog(title, null, positiveStr, negativeStr,popType,showEditText);
    }

    /**
     * 两个按键提示框
     *
     * @param title                 题目
     * @param positiveStr           确定按键文字
     * @param negativeStr           取消按键文字
     * @see [类、类#方法、类#成员]
     */
    public void showTwoDialog(String title, String positiveStr, String negativeStr,String popType,boolean isCancelable) {
        showDialog(title, null, positiveStr, negativeStr,popType,isCancelable);
    }

    /**
     * 带message提示框
     *
     * @param title                 题目
     * @param content               内容
     * @param positiveStr           确定按键文字
     * @param negativeStr           取消按键文字
     * @see [类、类#方法、类#成员]
     */
    public void showMessageDialog(String title, String content, String positiveStr, String negativeStr,String popType,boolean isCancelable) {
        showDialog(title, content, positiveStr, negativeStr,popType,isCancelable);
    }


    /**
     * 带message提示框
     *
     * @param title                 题目
     * @param content               内容
     * @param positiveStr           确定按键文字
     * @param negativeStr           取消按键文字
     * @see [类、类#方法、类#成员]
     */
    public void showMessageDialog(String title, String content, String positiveStr, String negativeStr,boolean isCancelable) {
        showDialog(title, content, positiveStr, negativeStr,isCancelable);
    }

    private void showDialog(String title, String content, String positiveStr, String negativeStr,boolean isCancelable) {

        if (AppManager.getAppManager().getActivity() != null &&AppManager.getAppManager().getActivity().isFinishing())
        {
            return;
        }

        Intent intent = new Intent(AppManager.getAppManager().getActivity(), DefaultDialog.class);
        intent.putExtra("title",title);
        intent.putExtra("content",content);
        intent.putExtra("positiveStr",positiveStr);
        intent.putExtra("negativeStr", negativeStr);
        intent.putExtra("isCancelable", isCancelable);
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        BCDApplication.getApp().startActivity(intent);



    }




    public void showDialog(String title, String content, String positiveStr, String negativeStr,String popType,boolean isCancelable) {

        if (AppManager.getAppManager().getActivity() != null &&AppManager.getAppManager().getActivity().isFinishing())
        {
            return;
        }



        Intent intent = new Intent(AppManager.getAppManager().getActivity(), DefaultDialog.class);
        intent.putExtra("title",title);
        intent.putExtra("content",content);
        intent.putExtra("positiveStr",positiveStr);
        intent.putExtra("negativeStr", negativeStr);
        intent.putExtra("popType",popType);
        intent.putExtra("isCancelable",isCancelable);
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        BCDApplication.getApp().startActivity(intent);

    }
    public void showDialog(String title, String content, String positiveStr, String negativeStr,String popType,boolean showEditText,boolean isCancelable) {

        if (AppManager.getAppManager().getActivity() != null &&AppManager.getAppManager().getActivity().isFinishing())
        {
            return;
        }

        Intent intent = new Intent(AppManager.getAppManager().getActivity(), DefaultDialog.class);
        intent.putExtra("title",title);
        intent.putExtra("content",content);
        intent.putExtra("positiveStr",positiveStr);
        intent.putExtra("negativeStr", negativeStr);
        intent.putExtra("popType",popType);
        intent.putExtra("showEditText",showEditText);
        intent.putExtra("isCancelable",isCancelable);
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        BCDApplication.getApp().startActivity(intent);

    }












}
